import requests

url = 'http://www.baidu.com/s?'

headers = {
    'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36',
    'Cookie':'BIDUPSID=F56C21D06BD742371B283C21F2438242; PSTM=1706440905; BAIDUID=01036CEB008DE2F59B611756BF86DC32:FG=1; BD_UPN=12314753; BDUSS_BFESS=VCUFp-NUpFZmJ0RzBzb0g1R3BTRnlmaGk0bkNINkpkN1YtbjdhN1lYN1o5c0ptSUFBQUFBJCQAAAAAAAAAAAEAAADEKueUsK5lYmlwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANlpm2bZaZtmeD; BDORZ=FFFB88E999055A3F8A630C64834BD6D0; BAIDUID_BFESS=01036CEB008DE2F59B611756BF86DC32:FG=1; BA_HECTOR=a021alagahag01200k8kak2h0j485u1jbtagq1u; ZFY=i7:A3M:A2omBVTbEtLnlOvenx6yN4PtvH0JcbKGLL:AR8g:C; H_PS_PSSID=60273_60566_60576_60359_60623; BDRCVFR[pRAxDSK7ZeD]=mk3SLVN4HKm; BD_CK_SAM=1; PSINO=7; delPer=0; COOKIE_SESSION=202_5_9_9_14_27_1_2_6_6_0_2_199_0_5_6_1723789101_1723363960_1723789096%7C9%232487_41_1723363954%7C8; H_WISE_SIDS=60273_60566_60576_60359_60623; H_PS_645EC=3d64Xb5lz6AmUbl9nMNzZEaNwBMqxpkTmBVBlxnrNn0cKqlGUDZVRjgY46VDbiFwU79Kk%2FI; H_WISE_SIDS_BFESS=60273_60566_60576_60359_60623; BDSVRTM=698; WWW_ST=1723790710642'
}

data = {
    'wd':'北京'
}

# get(url:请求地址, params:参数, kwargs)
response = requests.get(url=url, params=data, headers=headers)

# response.encoding = 'utf-8'

print(response.url)

content = response.text
print(content)

# 关闭
# response.close()

# 总结
# 1.参数使用params传递
# 2.参数无需urlencode编码
# 3.不需要请求对象的定制
# 4.请求资源中的？，可以不加